#pragma once

namespace trm {

///return first frame's number lieing out of span in given direction
inline int out_of_span(span const & s, direction dir)
	{ return (dir == backward) ? s.first-1 : s.last; }

///return last frame's number lieing inside of span in given direction
inline int last_of_span(span const & s, direction dir)
	{ return (dir == backward) ? s.first : s.last-1; }

inline int advance(span & s, direction dir)
	{ return (dir == backward) ? --s.first-1 : ++s.last; }

inline bool eos(span const & request, span const & s, direction dir)
	{ return (dir == backward) ? request.first >= s.first : request.last <= s.last; }

} //namespace trm
